Topic: Savings Account
Points: 25
Instructor: Dana Steil
Expected review Material:
You will be creating a class to represent a simple savings account with a few data members and functions.
#ifndef SAVINGS_ACCOUNT_H
#define SAVINGS_ACCOUNT_H
const int MAX_OWNER_LENGTH = 30;
class CSavingsAccount
{
public:
CSavingsAccount(const char* Owner,
const double MinimumBalance,
const double InitialBalance = 0);
double Balance();
static double AnnualInterestRate();
const char* Owner();
void CalculateMonthlyInterest();
void DepositFunds(const double Amount);
void WithdrawFunds(const double Amount, bool& Success);
static UpdateInterestRate(const double NewAnnualInterestRate);
private:
static const int TIMES_INTEREST_PAID_PER_YEAR;
static const int MAX_INTEREST_RATE;
static const int MIN_INTEREST_RATE;
const double MINIMUM_BALANCE;
double m_Balance;
char m_Owner[MAX_OWNER_LENGTH];
static double m_AnnualInterestRate;
bool ValidBalance( const double Balance);
static bool ValidInetestRate(const double InterestRate);
};
#endif
Filename:
SavingsAccount.cpp
Be sure each of the following functions are used.
CSavingsAccount(const char* Owner, const double MinimumBalance,
const double InitialBalance = 0); - For a savings account to be created an owner and minimum balance are required.
double Balance(); - Returns the balance of the savings account.
static double AnnualInterestRate(); - Returns the AnnualInterestRate.
const char* Owner(); - Returns a pointer to the Owner.
void CalculateMonthlyInterest(); - Calculates the monthly interest by multiplying the balance by the annual interest rate and then dividing that amount by the TIMES_INTEEST_PAID_PER_YEAR.
void DepositFunds(const double Amount); - adds the argument amount to the balance
void WithdrawFunds(const double Amount, bool& Success); - subtracts the argument amount from the balance. Check to make sure that the balance does not become negative. If the withdraw amount is greater than the balance do not remove any funds and set the Success flag to false.
static UpdateInterestRate(const double NewAnnualInterestRate, bool& Success); - Updates the interest rate. Checks to make sure the new interest rate is valid, if it is not the interest rate remains the same and the Success flag is set to false.
bool ValidBalance( const double Balance); - Utility function that returns true if the Balance is greater than or equal to the MIN_BALANCE, false otherwise.
static bool ValidInterestRate(const double InterestRate); - Utility function that returns true if the Interest rate is greater than or equal to the MIN_INTEREST_RATE and less than or equal to the MAX_INTEREST_RATE, false otherwise.
Write a test program that will:
1. Create multiple Savings Accounts using the each of its possible constructors.
2. Test each of the public member functions using the objects created above.
Each students test program may very. Part of your grade will reflect the thoroughness of your test program.